package npr;

import processing.core.*;

/**
 * Superclass for all line drawing algorithm. Provides line width and color.
 */
public abstract class Lines extends Algorithm{

    /** The red value of the line color. Ranges from 0.0 to 1.0. */
    protected float red;
    /** The green value of the line color. Ranges from 0.0 to 1.0. */
    protected float green;
    /** The blue value of the line color. Ranges from 0.0 to 1.0. */
    protected float blue;
    /** The alpha value of the line color. Ranges from 0.0 to 1.0. */
    protected float alpha;
    /** The line width */
    protected float width;


    /** 
    * Creates a Lines object. This class is not intended to be instantiated directly, only its various subclasses.
    * The line color will be initialized to black, and the width to 3.0.
    */
    public Lines(){
	red= 0.0f;
	green= 0.0f;
	blue= 0.0f;
	alpha= 1.0f;
	width= 3.0f;
    }

    /**
     * Sets the line width.
     *
     *
     * @param width line width.
     */

    public void setWidth(float width){
	this.width= width;
    }


    /**
     * Sets the line color to a gray value. Alpha will be set to 255.
     * 
     * @param gray the gray value between 0 and 255.
     */ 
    public void setColor(int gray){
	setColor(gray, gray, gray, 255);
    }

    /**
     * Sets the line color to a gray value and the alpha to specified alpha value.
     * 
     * @param gray the gray value between 0 and 255.
     * @param alpha the alpha value between 0 and 255.
     */

    public void setColor(int gray, int alpha){
	setColor(gray, gray, gray, alpha);
    }


    /**
     * Sets the line color to specified RGB values. Alpha will be set to 255.
     * 
     * @param r the red value between 0 and 255
     * @param g the green value between 0 and 255
     * @param b the blue value between 0 and 255
     */

    public void setColor(int r, int g, int b){
	setColor(r, g, b, 255);
    }


    /**
     * Sets the line color to specified RGBA value
     * 
     * @param r the red value between 0 and 255
     * @param g the green value between 0 and 255
     * @param b the blue value between 0 and 255
     * @param a the alpha value between 0 and 255
     */

    public void setColor(int r, int g, int b, int a) {
	setColor((float)r/255.0f, (float)g/255.0f, (float)b/255.0f, (float)a/255.0f);
    }


    /**
     * Sets the line color to a gray value. Alpha will be set to 1.0.
     * 
     * @param gray the gray value between 0.0 and 1.0
     */

    public void setColor(float gray) {
	setColor(gray, gray, gray, 1.0f);
    }


    /**
     * Sets the line color to a gray value and the alpha to specified alpha value.
     * 
     * @param gray the gray value between 0.0 and 1.0
     * @param alpha the alpha value between 0.0 and 1.0
     */

    public void setColor(float gray, float alpha) {
	setColor(gray, gray, gray, alpha);
    }


    /**
     * Sets the line color to specified RGB values. Alpha will be set to 1.0.
     * 
     * @param r the red value between 0.0 and 1.0
     * @param g the green value between 0.0 and 1.0
     * @param b the blue value between 0.0 and 1.0
     */

    public void setColor(float r, float g, float b) {
	setColor(r, g, b, 1.0f);
    }


    /**
     * Sets the line color to specified RGBA value
     * 
     * @param r the red value between 0.0 and 1.0
     * @param g the green value between 0.0 and 1.0
     * @param b the blue value between 0.0 and 1.0
     * @param a the alpha value between 0.0 and 1.0
     */
    
    public void setColor(float r, float g, float b, float a) {
	red= r; 
	blue= b; 
	green= g; 
	alpha= a;
    }

}